package com.aaa.market.controller;


import com.aaa.market.pojo.entity.Question;
import com.aaa.market.pojo.vo.QuestionVo;
import com.aaa.market.service.QuestionService;
import com.alibaba.fastjson.JSON;
import com.gsj.common.pojo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: clms-eighth
 * @description: 客服问题的控制层
 * @author: 刘守霖
 * @create: 2021-07-23 20:04
 **/
@RestController
@RequestMapping("/market/question")
@Api(description = "客服问题")
public class QuestionController {
    @Autowired
    private QuestionService questionService;

    @PostMapping("initQuestionTable/{currentPage}/{pageSize}")
    @ApiOperation(value = "查询客服问题表",httpMethod="POST")
    public R initQuestionTable(@PathVariable("currentPage")Integer currentPage,
                               @PathVariable("pageSize")Integer pageSize,
                               @RequestBody QuestionVo questionVo){
        return questionService.findQuestionByPage(currentPage,pageSize,questionVo);
    }
    //新增
    @PostMapping("addbyQuestionId")
    @ApiOperation(value = "新增客服问题列表",httpMethod="POST")
    public R addbyQuestionId(@RequestBody Question question){
        return questionService.insertQuestion(question);
    }
    //删除
    @DeleteMapping("delQuestion")
    @ApiOperation(value = "根据id删除客服问题",httpMethod="DELETE")
    public R delQuestion(Integer id){
        return questionService.delQuestion(id);
    }
    //修改
    @PostMapping("changeQuestion")
    @ApiOperation(value = "修改客服问题数据",httpMethod="POST")
    public R changeQuestion(@RequestBody Question question){
        return questionService.changeQuestion(question);
    }
    @GetMapping("chaXun")
    @ApiOperation(value = "修改前将数据回显到表单",httpMethod="GET")
    public R chaXun(Integer id){
        return questionService.chaXun(id);
    }

    @PostMapping("customerIssues")
    public R customerIssues(@RequestBody QuestionVo questionVo){
        return questionService.customerIssues(questionVo);
    }
}
